package com.example.demo.controller;

import com.example.demo.dto.ResponseResult;
import com.example.demo.dto.UserServiceStatusDTO;
import com.example.demo.entity.UserService;
import com.example.demo.service.impl.UserServiceServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("app/user_service")
public class UserServiceController {
    @Autowired
    private UserServiceServiceImpl userServiceServiceImpl;

    //创建用户服务
    @PostMapping("/post/create")
    public ResponseResult<UserService> createUserService(@RequestParam String orderNo)
    {
        UserService userService = userServiceServiceImpl.createUserService(orderNo);
        return new ResponseResult<>(200,"success",userService);
    }

    //判断用户是否购买服务
    @GetMapping("/get/checkVoicePurchase/{user_id}")
    public ResponseResult<UserServiceStatusDTO> checkVoicePurchase(@PathVariable int user_id) {
        UserServiceStatusDTO userServiceStatusDTO = userServiceServiceImpl.getIsPurchaseAndExpiryTimeById(user_id);
        return new ResponseResult<>(200,"success",userServiceStatusDTO);
    }

}
